<!DOCTYPE html>
<html>

<head>
    <title>北京站网格化系统</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Fonts -->
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/dataTables.bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/validform.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/js/jquery-treegrid-master/jquery.treegrid.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="../lib/css/common/style.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/themes/flat-blue.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/newstyle.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/baseCommon.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/zc-common.css">     
</head>

<body class="flat-blue">
    <div class="app-container expanded">
        <div class="row content-container">
             <nav class="navbar navbar-default navbar-fixed-top navbar-top">
                <div class="container-fluid app-header">
                   <div class="navbar-header">
                        <button type="button" class="navbar-expand-toggle fa-rotate-90">
                            <i class="fa fa-bars icon"></i>
                        </button>
                        <top-nav></top-nav>
                    </div>
                    <right-info></right-info>
                </div>
            </nav>
            <div class="side-menu-wrap">
                <side-menu></side-menu>
            </div> 
            <!-- Main Content -->
            <div class="container-fluid">
                <div class="side-body padding-top">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card card_list">
                                <!-- 表格 -->
                                <div class="elm-wrap">
                                    <button type="button" class="btn btn-info" onclick="editing('post')">添加岗位</button>
                                </div>
                                <div class="elm-wrap table_style">
                                    <table id="table_id_example"  class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                                                <th>岗位名称</th>
                                                <th>岗位说明</th>
                                                <th>所属部门</th>
                                                <th>岗位类别</th>
                                                <th>作业人员</th>
                                                <th>责任网格</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tfoot>
                                            <tr>
                                                <th>岗位名称</th>
                                                <th>岗位说明</th>
                                                <th>所属部门</th>
                                                <th>岗位类别</th>
                                                <th>作业人员</th>
                                                <th>责任网格</th>
                                                <th>操作</th>
                                            </tr>
                                        </tfoot>
                                        <tbody class="table_body">
                                        </tbody>
                                </table>
                                </div>      
                            </div>
                            <div class="card card_edit">
                                    
                                <div class="card-body">
                                    <form class="form-horizontal postvue ss_form" style="margin-top:30px">
                                        <div class="form-group">
                                            <label for="post_name" class="col-sm-2 control-label">岗位名称： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <input type="text" class="form-control post_name" id="post_name" name="post_name" datatype="*" errormsg="请填写正确的岗位名称" nullmsg="岗位名称是必填的" placeholder="请输入岗位名称" v-model="info.post_name">
                                                <span class='Validform_checktip' />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="dep" class="col-sm-2 control-label">所属部门： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <select class="form-control dep" name="dep" id="dep" aria-placeholder="所属部门" style="width:100%" v-select2="{url:url.base+url.department+'department_list',multiple:false}" v-model="info.department_id" datatype="select2" errormsg="请选择所属部门" nullmsg="请选择所属部门"></select> 
                                                <span class='Validform_checktip' />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="grid" class="col-sm-2 control-label">责任网格： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <select class="form-control grid" name="grid" id="grid" aria-placeholder="请添加责任网格" style="width:100%" multiple v-select2="{url:url.base+url.grid+'grid_choice_list'}" v-model="info.post_grid" datatype="select2" errormsg="请填写正确的岗位名称" nullmsg="岗位名称是必填的">
                                                </select> 
                                                <span class='Validform_checktip' />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="dep" class="col-sm-2 control-label">岗位类别：</label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <div class="radio3 radio-check radio-blue radio-inline">
                                                    <input type="radio" id="radio4" v-model="info.post_type_id" name="post_type" value="2">
                                                    <label for="radio4">
                                                        作业岗位
                                                    </label>
                                                </div>
                                                <div class="radio3 radio-check radio-blue radio-inline">
                                                    <input type="radio" id="radio5" v-model="info.post_type_id" name="post_type" value="1">
                                                    <label for="radio5">
                                                        作业人员
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group" v-if="showUser">
                                            <label for="post_user" class="col-sm-2 control-label">作业人员： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <input id="userid" type="hidden" datatype="ztreegroup"  errormsg="请选择作业人员" nullmsg="请选择作业人员">
                                                <div class="departSelect">
                                                    <div type="text" class="form-control user tagselect" id="user" name="user" placeholder=""></div>
                                                    <div id="usergroup" class="groudtree"></div>    
                                                </div>
                                                <span class='Validform_checktip' /> 
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="duty" class="col-sm-2 control-label">岗位职能： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <select class="form-control duty" name="duty" id="duty" aria-placeholder="请选择岗位职能" v-model="info.post_duty">
                                                    <option value="1">维修</option>
                                                    <option value="3">作业</option>
                                                </select> 
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="post_desc" class="col-sm-2 control-label">岗位说明： </label>
                                            <div class="col-sm-10 col-md-6 col-lg-4">
                                                <textarea name="post_desc" class="form-control post_desc" rows="3" v-model="info.post_desc"></textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button type="button" class="btn btn-info edited" onclick="uploadData('post')">添加岗位</button>
                                                <button type="button" class="btn btn-default edit_cancel">取消</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            
                        </div>
                    </div>
                </div>
            </div>
            
        </div>
        <div class="modal fade" id="modalDel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">删除岗位</h4>
                    </div>
                    <div class="modal-body">
                        确定删除岗位？
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-info deling">确认</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="modalTips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel3">提示</h4>
                    </div>
                    <div class="modal-body">
                        温馨提示
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<!-- Javascript Libs -->
<script type="text/javascript" src="../lib/js/jquery.min.js"></script>
<script type="text/javascript" src="../lib/js/common/base.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.matchHeight-min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
<script type="text/javascript" src="../lib/js/datetimepicker.js"></script>
<script type="text/javascript" src="../lib/js/validform.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.bootstrap3.js"></script>
<script type="text/javascript" src="../lib/js/jquery-treegrid-master/jquery.treegrid.extension.js"></script>
<script type="text/javascript" src="../lib/js/depchoice/edep_plugin.js"></script>
<script type="text/javascript" src="../lib/js/ztreeJs.js"></script>
<script src="../lib/js/vue.js"></script>
<!-- <script type="text/javascript" src="../lib/js/ace/ace.js"></script>
<script type="text/javascript" src="../lib/js/ace/mode-html.js"></script>
<script type="text/javascript" src="../lib/js/ace/theme-github.js"></script> -->
<!-- Javascript -->
<script type="text/javascript" src="../lib/js/common/app.js"></script>
<script src="../lib/js/organization.js"></script>

<script>
    navData.accNav1 = 'organization'
    navData.nav1Name = '组织管理'
    navData.accNav2 = 'organization-base'
    navData.accNav3 = '2'
    var navVue = new Vue({
        el:'.side-menu-wrap' 
    })
    var navTopVue = new Vue({
        el:'.app-header' 
    })
    var Info={}
    //翻页条件
    var _upData={
        'page':1,
        'count':10
    }
    var _dataTable = $("#table_id_example").DataTable({
        "dom": '<"top"fl<"clear">>rt<"bottom"ip<"clear">>',
        language:{
            url: '../lib/js/cn_lang.json'
        },
        serverSide:true,
        ajax:function(data,callback,settings){
            //console.log('data',data)
            $('.table').loading('open','加载中。。。')
            // console.log(data)
            _upData.page = (data.start / data.length)+1;//当前页码
            _upData.count = data.length;//每页个数
            _upData.w = data.search.value;//搜索
            console.log(_upData)
            $.ajax({
                url:serverUrl.base + serverUrl.post + 'post_list',
                type:"POST",
                data:_upData,
                cache: false,
                dataType:"json",
                success:function(res){
                    _noEditElm = true
                    if(res.code == 0){
                        // $('.tablepagewrap').html(res.result_page)
                        res.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                        res.recordsTotal = res.total;//返回数据全部记录
                        res.recordsFiltered = res.total;//后台不实现过滤功能，每次查询均视作全部结果
                        callback(res)
                    }        
                },
                complete:function(res){
                    $('body').loading('close')
                    $('.table').loading('close')
                },
                error:function(res){
                    
                }    
            })
        },
        // ajax:{
        //     url:serverUrl.base + serverUrl.post + 'post_list',
        //     type:'post',
        //     data:{
        //         _:Math.random()
        //     },
        //     complete:function(){
        //         $('body').loading('close')
        //     }
        // },
        ordering:false,
        columns:[
            { "data": "post_name" },
            { "data": "post_desc",width:"15%" },
            { "data": "department_name" },
            { "data": "post_type_name" },
            { "data": "post_user",width:"25%"},
            { "data": "post_grid",width:"25%"},
            {
                "data":null,render:function(data, type, row, meta){
                    //console.log()
                    return '<a onclick="editing(\'post\',this)" href="javascript:void(0)">编辑</a> <a onclick="delingModal(\'post\',this)" href="javascript:void(0)">删除</a>'
                },defaultContent:''
            }
            
        ]  
    })
    
    // 编辑
    function editing(name,elm){
        switch(name){
            case 'post':
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {
                    post_name:'',
                    post_type_id:1,
                    department_id:'',
                    department_name:'',
                    post_user:[],
                    post_desc:'',
                    post_grid:[],
                    post_duty:'1'
                }
                $('#userid').val('')
                $('#user').html('')
                
                $('.Validform_wrong').text('').removeClass('Validform_wrong')
                $('.Validform_error').text('').removeClass('Validform_error')
                $('.select2-selection').css('border-color','#ccc')
                myValidform.resetForm()
                if(arguments[1]){
    
                    $('.edited').text('编辑岗位')
                    Info =$.extend({},_dataTable.row($(elm).parents('tr')).data()) 
                    $.post(serverUrl.base+serverUrl.post+'post_info',{post_id:Info.post_id},function(res){
                        Info = $.extend({},Info,res.data)
                        posVue.info = Info
                        tagSelected({data:Info.post_user,elmName:'user',dataName:'userid',init:true})
                        $('input[name="post_type"]').prop('disabled',true)
                        //作业人员列表
                        // tagSelected({data:Info.post_user,elmName:'user',delFn:function(elm,id,data){
                        //     Info.post_user = Info.post_user.filter(function(v){
                        //         return v.id != id
                        //     })   
                        //     Info._post_user_id=[]
                        //     $.each(Info.post_user,function(val,elm){
                        //         Info._post_user_id.push(elm.id)
                        //     })
                        //     $('#userid').val(Info._post_user_id.join(','))
                        // }}) //复选树初始化
                        
                        // Info._post_user_id = []
                        // $.each(Info.post_user,function(val,elm){
                        //     Info._post_user_id.push(elm.id)
                        // })
                        // $('#userid').val(Info._post_user_id.join(','))

                        //$('select.grid').val(Info.post_grid).trigger('change')//select2 选择框初始化
                        
                    },'json')
                }else{
                    $('.edited').text('添加岗位')
                    posVue.info = Info
                    $('input[name="post_type"]').prop('disabled',false)
                    
                }
                
                
            break;
            default:
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {}
            break;
        }
        if(arguments[1]){
            Info.row = $(elm).parents('tr')
        }
    }
    // 删除
    function delingModal(name,elm){
        switch(name){
            case 'post':
                Info.row = $(elm).parents('tr')
                _id = _dataTable.row(Info.row).data().post_id
                var _text={
                    tit:'删除岗位',
                    body1:'确定删除岗位？',
                    body2:'当前岗位与接发车作业任务、量化任务、设备维修/巡检/验收任务、应急处置等模块相关联，删除后会影响部分功能无法正常使用，请先取消与相关模块的关联后再删除此岗位。',
                    btn1:'确定',
                    cbtn1:'取消',
                    cbtn2:'知道了'
                }
                $.post(serverUrl.base+serverUrl.post+'can_del',{post_id:_id},function(res){
                    if(res.code == 0){
                        $('#modalDel').find('.modal-body').text(_text.body1)
                        $('#modalDel').find('.modal-footer .deling').show()
                        $('#modalDel').find('.modal-footer .cancel').text(_text.cbtn1)
                    }else if(res.code == 1){
                        $('#modalDel').find('.modal-body').text(_text.body2)
                        $('#modalDel').find('.modal-footer .cancel').text(_text.cbtn2)
                        $('#modalDel').find('.modal-footer .deling').hide()
                    }
                    $('#modalDel').modal()
                },'json')
            break;
            default:
            break;
        }
    }
    $('.deling').on('click',function(){
        $('#modalDel').modal('hide')
        var _id = _dataTable.row(Info.row).data().post_id;
        $('.card_list').loading('open')
        $.post(serverUrl.base+serverUrl.post+'del_post',{post_id:_id},function(res){
            if(res.code == 0){
                setTimeout(function(){
                    $('#modalTips').find('.modal-body').text(res.info)
                    $("#modalTips").modal()    
                },500)
                _dataTable.row(Info.row).remove().draw(false)
            }else{
                setTimeout(function(){
                    $('#modalTips').find('.modal-body').text(res.info)
                    $("#modalTips").modal()    
                },500)
            }
        },'json').complete(function(){
            $('.card_list').loading('close')
        })
    })
    
    Vue.directive('select2', {
        bind:function(el,binding){
            // console.log(el)
            // if(binding.value.valide && binding.value.valide != ''){
            //     $(el).off('change').on('change',function(){
            //         console.log(posVue.valid == binding.value.valide)
            //         myValidform.check(false,$(el))
            //     })
            // }
        },
        inserted: function (el, binding, vnode) {
            //console.log(binding.value)
            var opts = $.extend({
                isId:false,
                sel:'',
                url:'',
                type:'POST',
                baseData:{sel:1},
                data:{},
                datas:[],
                multiple:true,
                placeholder:'请选择选项',
                valide:'',
                hasAll:false
            },binding.value||{});
            //console.log(opts)
            if(opts.url){
                var _data = $.extend({},opts.baseData,opts.data)
                $.ajax({
                    url:opts.url,
                    type:opts.type,
                    data:_data,
                    dataType:"json",
                    success:function(res){
                        if(res.code == 0){
                            opts.datas = res.data
                            if(opts.hasAll){
                                opts.datas.splice(0,0,{id:'none',text:'全部'})
                            }   
                        }
                        $(el).select2({
                            placeholder:opts.placeholder,
                            data:opts.datas,
                            multiple:opts.multiple,
                            closeOnSelect:!opts.multiple
                        })
                        
                        // if(opts.valide && opts.valide != ''){
                        //     $(el).on('change',function(){
                        //         console.log(el)
                        //     })
                        //     $(el).on("select2:close", function (e) {
                        //         var _check = opts.valide.check(false,$(e.currentTarget))
                        //     });
                        //     $(el).on("select2:select", function (e) {
                        //         var _check = opts.valide.check(false,$(e.currentTarget))
                        //     });
                        //     $(el).on("select2:unselect", function (e) {
                        //         var _check = opts.valide.check(false,$(e.currentTarget))
                        //         //console.log(_check)
                        //     });
                        // }
                        
                    },
                    complete:function(res){
                        
                    },
                    error:function(res){
                        console.log(res)
                    }    
                })
            }else{
                if(opts.datas.length != 0){
                    setTimeout(function(){//延迟一下 vue数据更新时就不会出现无法使用的问题了
                        if(opts.hasAll){
                            opts.datas.splice(0,0,{id:'none',text:'全部'})
                        }
                        $(el).select2({
                            placeholder:opts.placeholder,
                            data:opts.datas,
                            multiple: opts.multiple,
                            closeOnSelect: !opts.multiple
                        })
                        // if(opts.valide && opts.valide != ''){
                        //     $(el).on("select2:close", function (e) {
                        //         var _check = opts.valide.check(false,$(e.currentTarget))
                        //     });
                        //     $(el).on("select2:select", function (e) {
                        //         var _check = opts.valide.check(false,$(e.currentTarget))
                        //     });
                        //     $(el).on("select2:unselect", function (e) {
                        //         opts.valide.check(false,$(e.currentTarget))
                        //     });
                        // }
                    },0)
                }
            }
            
            $(el).on("select2:select", function(e){
                //$(el).change()
                 el.dispatchEvent(new Event('change', { target: e.target }));
            });
            $(el).on("select2:unselect", function(e){
                //$(el).change()
                 el.dispatchEvent(new Event('change', { target: e.target }));
            });
            
            
        },
        update: function (el, binding, vnode) {
            //console.log(posVue.gogo,posVue.gogo2)
            for(var i=0;i<vnode.data.directives.length;i++){
                if(vnode.data.directives[i].name=='model'){
                    $(el).val(vnode.data.directives[i].value)
                }
            }
            $(el).trigger("change");
        }
    });
    var posVue = new Vue({
        el:'.postvue',
        data:{
            info:{
                post_name:'',
                post_type_id:1,
                department_id:'',
                department_name:'',
                post_user:[],
                post_desc:'',
                post_grid:[],
                post_duty:'1'
            },
            url:vueStore.state.serverUrl
        },
        computed:{
            showUser:function(){
                return this.info.post_type_id != '2'
            }
        },
        methods:{

        },
        watch:{
            
        },
        beforeUpdate:function(){
            
            //console.log($("#userid").val())
        },
        updated:function(){  
        }
    })
    // 保存修改
    function uploadData(name){
        switch(name){
            case 'post':
                if(!myValidform.check()){
                    return false
                }
                var _info = posVue.info,
                _upData={
                    post_id:_info.post_id,
                    post_name:_info.post_name,
                    post_type_id:_info.post_type_id,
                    post_grid:_info.post_grid,
                    department_id:_info.department_id,
                    post_user:_info.post_type_id == '1'?$('#userid').val()?$('#userid').val():[]:null,
                    post_desc:_info.post_desc,
                    post_duty:_info.post_duty
                }
                //console.log(_upData)
                //return false
                $('.card_edit').loading('open')
                // return false
                $.ajax({
                    url:serverUrl.base+serverUrl.post+'edit_post',
                    type:"POST",
                    data:_upData,
                    dataType:"json",
                    success:function(res){
                        if(res.code == 0){
                            _upData.department_name = Info.department_name
                            _upData._post_grid=[]
                            var _g=$('select.grid').select2('data')
                            for(var i=0;i<_g.length;i++){
                                _upData._post_grid.push(_g[i].text)
                            }
                            _upData.post_grid = _upData._post_grid.join('，')
                            if(_upData.post_type_id == '1'){
                                _upData.post_type_name = '作业人员'
                            }else{
                                _upData.post_type_name = '作业岗位'
                            }
                            var _t = $('#user').find('.circleGird')
                            _upData._post_user = []
                            _t.each(function(id,elm){
                                _upData._post_user.push($(elm).text())
                            })
                            _upData.post_user = _upData._post_user.join('，')
                            //更新表格
                            // _dataTable.settings()[0].ajax.data={'department_id':Info.department_id}
                            
                            if(Info.row){
                                _dataTable.ajax.reload(function(){},false)
                                // _dataTable.row(Info.row).data(_upData).draw(false)
                            }else{
                                // _dataTable.row.add(_upData).draw(false)
                                _dataTable.ajax.reload()
                            }
                            Info = {}
                            $('.card_edit').hide()
                            $('.card_list').show()
                            $("#modalTips").find('.modal-title').text('成功') 
                            var _info=''
                            if($('.edited').text() ==  '添加岗位'){
                                _info = '添加岗位成功！'
                            }else{
                                _info = '修改岗位成功！'
                            }
                            $("#modalTips").find('.modal-body').text(_info)
                        }else if(res.code == '2'){
                            $("#modalTips").find('.modal-title').text('出现问题') 
                            $("#modalTips").find('.modal-body').text(res.info)
                        }
                        setTimeout(function(){
                            $("#modalTips").modal()    
                        },500)

                    },
                    complete:function(res){
                        $('#modalDel').modal('hide')
                        $('.card_edit').loading('close')
                    },
                    error:function(res){
                        $("#modalTips").find('.modal-title').text('出现问题') 
                        $("#modalTips").find('.modal-body').text(res.info)
                        setTimeout(function(){
                            $("#modalTips").modal()    
                        },500)
                    }    
                })
            break;
        }
    }
    //取消
    $(".edit_cancel").on('click',function(){
        $(".card_list").show();
        $(".card_edit").hide();
        Info={}
    })
    var datas = {
        grids:[
            {id:'1',text:'候车1'},
            {id:'2',text:'候车2'},
            {id:'3',text:'候车3'},
            {id:'4',text:'候车4'},
            {id:'5',text:'候车5'}
        ],
        xsStandard:[
            {id:'1',text:'2小时'},
            {id:'2',text:'6小时'},
            {id:'3',text:'8小时'},
            {id:'4',text:'12小时'}
        ],
        gridTips:[
            {id:'1',text:'站台区'},
            {id:'2',text:'候车区'},
            {id:'3',text:'厕所'},
            {id:'4',text:'售票厅'}
        ]
    }
    // var myValidform = $(".ss_form").Validform({
    //     tiptype:2,
    //     datatype:{
    //         ztreegroup:function(gets,obj,curform,regxp){
    //             console.log(gets)
    //             if(gets == ''){
    //                 return false
    //             }else{
    //             }
    //         },
    //         select2:function(gets,obj,curform,regxp){
    //             if(gets.length ==0){
    //                 $('.select2-selection').css('borderColor','red')
    //                 return false
    //             }else{
    //                 $('.select2-selection').css('borderColor','#ccc')
    //             }
    //         }
    //     }
    // });
    var myValidform = $(".ss_form").Validform({
        tiptype:3,
        datatype:{
            putso:function(gets,obj,curform,regxp){
                /*参数gets是获取到的表单元素值，
				  obj为当前表单元素，
				  curform为当前验证的表单，
				  regxp为内置的一些正则表达式的引用。*/
                var _checkpwrap = obj.parents('.checkpwrap')
                var _type = _checkpwrap.find('.checkp').val()
                var _userid = _checkpwrap.find('.userid').val()
                var _post = _checkpwrap.find('.post').val()
                var reg1=regxp["*"],
					reg2=/[\d]{7}/,
					mobile=curform.find(".mobile");
                if(obj){
                    if(_type == '1'){
                        //人
                        //console.log(_userid)
                        if(reg1.test(_userid)){return true;}
                    }else if(_type == '3'){
                        //岗位
                        if(reg1.test(_post)){return true;}
                    }
                }
                return false;
            },
            ztreegroup:function(gets,obj,curform,regxp){
                console.log(gets)
                if(gets == ''){
                    return false
                }else{
                }
            },
            select2:function(gets,obj,curform,regxp){
                console.log(gets)
                if(gets.length ==0 || gets == null || gets == ''){
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','red')
                    return false
                }else{
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','#ccc')
                }
            }
        }
    });
    $(document).on('click','.user',function(){
       // console.log($('#userid').val())
        showsDeptWin('user','userid','1',myValidform);
    })
    // new rpSelect({
    //     sel:'dep',
    //     url:serverUrl.base+serverUrl.department+'department_list',
    //     multiple:false,
    //     placeholder:'选择部门'
    // })
    // new rpSelect({
    //     sel:'grid',
    //     url:serverUrl.base+serverUrl.grid+'grid_choice_list',
    //     placeholder:'选择责任网格'
    // })
    

</script>
</html>
